from langchain_openai import ChatOpenAI
import os
from dotenv import load_dotenv
from com.wp.langchain.simpleDemo import config

load_dotenv()

model = ChatOpenAI(temperature=0.7,
                   model_name=os.getenv("LLM_CHAT_MODEL"),
                   api_key=os.getenv("LLM_API_KEY"),
                   base_url=os.getenv("LLM_BASE_URL"))

from langchain_core.messages import HumanMessage, SystemMessage
messages = [
    SystemMessage(content="Translate the following from English into chainese."),
    HumanMessage(content="Who won the FIFA World Cup in the year 1994?")
]
response = model.invoke(messages)
print(response)

from langchain_core.output_parsers import StrOutputParser
parser = StrOutputParser()
invoke = parser.invoke(response)
print(invoke)

chain = model | parser
response = chain.invoke(messages)
print(response)
